package st;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lm.models.BigramModel;
import lm.models.UnigramModel;
import st.utils.LexicalProb;
import st.utils.ReadTags;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		LexicalProb.createLexicalProb("train.pos");

		String[] training = ReadTags.readTags("train.pos");

		System.out.println("\n----------------------------------------------");
		UnigramModel unigramModelForBigram2 = new UnigramModel(training, false);
		BigramModel bigramModel2 = new BigramModel(unigramModelForBigram2
				.getUnigramModel(), training, false);

		List<String> tagSet = new ArrayList<String>();

		for (String tag : training) {
			if (!tagSet.contains(tag)) {
				tagSet.add(tag);
			}
		}

		try {
			// Open the file that is the first
			// command line parameter
			FileInputStream fstream = new FileInputStream("test-obs.pos");

			// Get the object of DataInputStream
			DataInputStream in = new DataInputStream(fstream);
			InputStreamReader inputStreamReader = new InputStreamReader(in);
			BufferedReader br = new BufferedReader(inputStreamReader);
			String strLine;
			List<String> inputWords = new ArrayList<String>();

			// Read File Line By Line
			while ((strLine = br.readLine()) != null) {
				inputWords.add(strLine);
			}

			Viterbi viterbi = new Viterbi( bigramModel2,
					tagSet, inputWords);
			viterbi.runViterbi();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
